<template>
  <div class="total-gender">
    <div class="wrapper">
      <img
        class="left"
        src="http://img.alicdn.com/tfs/TB1p9Luq8v0gK0jSZKbXXbK2FXa-500-500.png"
        alt=""
      />
      <div class="right">
        <div class="totalNum">男性用户人数</div>
        <div class="numInEng">Number of male users</div>
        <div >
          <count-to
            class="num"
            :start-val="startMale"
            :end-val="endMalVal"
            :duration="1000"
        
          />
          <span>万人</span>
        </div>
      </div>
    </div>
    <div class="wrapper">
      <img
        class="left"
        src="http://img.alicdn.com/tfs/TB1p9Luq8v0gK0jSZKbXXbK2FXa-500-500.png"
        alt=""
      />
      <div class="right">
        <div class="totalNum">女性用户人数</div>
        <div class="numInEng">Number of female users</div>
        <div>
          <count-to
            class="num"
            :start-val="startFemale"
            :end-val="endFemalVal"
            :duration="1000"
         
          />
          <span>万人</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Echarts from "echarts";
import { ref, watch } from "vue";

export default {
  name: "TotalGender",
  props: {
    data: Array,
  },
  setup(props) {
    const startMaleVal = ref(0);
    const endMalVal = ref(0);
    const startFemaleVal = ref(0);
    const endFemalVal = ref(0);

    watch(
      () => props.data,
      (newData) => {
        startMaleVal.value = endMalVal.value;
        endMalVal.value = newData[0].value;
        startFemaleVal.value = endFemalVal.value;
        endFemalVal.value = newData[1].value;
      }
    );

    return {
      startMaleVal,
      startFemaleVal,
      endMalVal,
      endFemalVal,
    };
  },
};
</script>

<style lang="scss" scoped>
.total-gender {
  width: 100%;
  height: 100%;
  display: flex;
  background: rgb(43, 44, 46);
  .wrapper {
    width: 50%;
    height: 100%;
    display: flex;
    justify-content: center;
    .left {
      width: 75px;
      height: 75px;
      margin: 40px 40px 0 0;
    }
    .right {
      display: flex;
      flex-direction: column;
      margin-top: 20px;
      .totalNum {
        font-size: 30px;
        margin-top: 16px;
      }
      .numInEng {
        font-size: 18px;
        margin-top: 16px;
      }
      .num {
        font-size: 46px;
        font-family: DIN;
        font-weight: bold;
        margin-top: 16px;
        display: inline-block;
        span {
          font-size: 18px;
        }
      }
    }
  }
}
</style>
